package com.jdb.loan.api.query;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

@Data
@NoArgsConstructor
public final class AmountCondition extends LoanCondition{

    /**
     * 额度-最小
     */
    private Integer quotaMin;

    /**
     * 额度-最大
     */
    private Integer quotaMax;

    public AmountCondition(String id, String name, Integer quotaMin, Integer quotaMax) {
        setId(id);
        setName(name);
        setQuotaMin(quotaMin);
        setQuotaMax(quotaMax);
        setType("amount");
    }


    public boolean isMinAndMax() {

        if (Objects.isNull(getQuotaMin())) {
            return false;
        }
        if (Objects.isNull(getQuotaMax())) {
            return false;
        }
        return true;
    }

    public boolean isMin() {
        return Objects.nonNull(getQuotaMin()) && Objects.isNull(getQuotaMax());
    }

    public boolean isMax() {
        return Objects.nonNull(getQuotaMax()) && Objects.isNull(getQuotaMin());
    }
}
